//
//  Tools.m
//  day-02-TopView
//
//  Created by hcios on 2017/6/30.
//  Copyright © 2017年 hcios. All rights reserved.
//

#import "Tools.h"

@implementation Tools

NSString* NonEmptyString(id obj){
    
    if (obj == nil || obj == [NSNull null] || ([obj isKindOfClass:[NSString class]] && [obj length] == 0)) {
        return @"";
    }else if([obj isEqualToString:@"null"]){
        return @"";
    }else if([obj isKindOfClass:[NSNumber class]]){
        return NonEmptyString([obj stringValue]);
    }
    return obj;
}


NSString* numberToString(NSNumber * obj){
    
    if ([obj isKindOfClass:[NSNumber class]] && obj != nil) {
        NSString *numberToString = [NSString stringWithFormat:@"%@",obj];
        return numberToString;
    }else{
        return @"";
    }
}

+(int)getRandomNumber:(int)from to:(int)to{
    return (int)(from + (arc4random() % (to-from + 1)));
}

@end
